**********************************************************
* Introducing the CATD dataset
**********************************************************

* Data loading
**************

  use "CATD_agencies", clear
  sort num1 
  merge num1 using "CATD_donors"
  drop if _merge==2
  drop _merge
  sort ourid
  merge ourid using "Other variables"
  drop if _merge==2
  drop _merge
  sort ourid

  
* Figures
*********

* Figure 1
  
  preserve
	gsort -t 
	keep in 1/25
	g mt=-t
	graph bar t, over(abb, sort(mt) label(angle(90))) scheme(s1mono) ytitle(CATD index)  
  restore

  
* Table 3 

** pw_index  (Pagashvili and Williamson 2021)
  preserve
   collapse (mean)t transparencypercent t1 t2, by(num1)
   pwcorr transparencypercent t, sig star(.05)
  restore  
  
** gk_score  (Ghosh and Kharas 2011)
  preserve
   collapse (mean)t t1 t2 gk_transparency, by(num1)
   pwcorr gk_transparency t, sig star(.05)
  restore   
  
** ep_transparency  (Easterly and Pfutze 2008)
  pwcorr ep_transparency t, sig star(.05)
  
** ATI  
  pwcorr ati_index t, sig star(.05)
  
** Honig & Weaver 2019
  pwcorr overall_16* t, sig star(.05)
 
 
* Figure 2 

  preserve
    keep if iso3=="GBR"|iso3=="DEU"|iso3=="USA"|iso3=="FRA"
	graph bar t if iso3=="FRA", over(abbreviation, sort(1) descending label(angle(90))) scheme(s1mono) ytitle(Transparency score)
    graph bar t if iso3=="DEU", over(abbreviation, sort(1) descending label(angle(90))) scheme(s1mono) ytitle(Transparency score)
	graph bar t if iso3=="GBR", over(abbreviation, sort(1) descending label(angle(90))) scheme(s1mono) ytitle(Transparency score)
    graph bar t if iso3=="USA", over(abbreviation, sort(1) descending label(angle(90))) scheme(s1mono) ytitle(Transparency score)
  restore  

  
* t-tests by type
  
  g main=oecdtype==1
  g mins=oecdtype==2
  g locgov=oecdtype==3
  g ecas=oecdtype==4
  g dfis=oecdtype==5
  tab oecdtype

  ttest t, by(main) une
  ttest t, by(mins) une
  ttest t, by(ecas) une
  ttest t, by(dfis) une
  
  
* Figure 3 

  g t_pamax=min(2022, t_pamin+t_pay)
  replace t_pamax=. if t_pamin==.|t_pay==.
  g t_stmax=min(2022, t_stmin+t_sty)
  replace t_stmax=. if t_stmin==.|t_sty==.
  replace t_admmin=2021 if t_admmin==1 
  su t_armax t_admmin t_stmax t_pamax
  foreach x in armax admmin stmax pamax{
  g _m`x'=min(0, t_`x'-2020)
  replace _m`x'=. if t_`x'==.
  }

  vioplot _marmax _madmmin _mstmax _mpamax, scheme(s1mono)  ylab(, angle(horiz)) noylab hor xtitle(Most recent year of coverage relative to reference year) ytitle(Category)
  su _marmax _madmmin _mstmax _mpamax


* Figure 4 

  g aryears=t_armax-t_armin
  su aryears t_admy t_sty t_recy t_secy t_chy t_pay
  vioplot aryears t_admy t_sty t_recy t_secy t_chy t_pay, scheme(s1mono) ylab(, angle(horiz)) noylab hor xtitle(Number of years of coverage) ytitle(Category)
  su aryears t_admy t_sty t_recy t_secy t_chy t_pay

  
* Table 4 

  su t_aeap if t_aeae==1
  su t_ami if t_am==1
  su t_oc if t_o==1
  su t_sts if t_st==1
  su t_std if t_st==1
  su t_tiati if t_t==1
  

* Figure 5 

  hist t_pau if t_pa!=., width(5) scheme(s1mono) percent
  su t_pau if t_pa!=.

  
* Figure 6 

  vioplot t*_n, scheme(s1mono) ylab(, angle(horiz)) noylab hor xtitle(Number of clicks required to access information) ytitle(Categories)
  su t*_n
  

* Figure 7

  egen Nhtml=rowtotal(*html)
  egen Npdf=rowtotal(*pdf)
  egen Ndb=rowtotal(*db)
  vioplot N*, scheme(s1mono) ylab(, angle(horiz)) noylab hor ytitle(Data formats) xtitle(Number of categories)
  
  
* Appendix
**********

* Table A1 

  g minust=-t
  sort country minust
  edit country iso3 ourid name abbreviation t t1 t2  
  drop minust

  
* Table A7

  pwcorr t t1 t2, sig
  
  
* Factor analysis available upon request *
  
  